// pages/index/newDetials.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    commentList:[],
    toView: "mark-1",
    page_height: 0
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var data = [
      { id: 1, nickname: '万里长征只等闲', commentTime: '03-20 15:15', commentContent: '谁说没有专业狙击手,抗日神剧神枪手一堆', zanNum: 300, img: '/public/images/3.jpg'},
      { id: 2, nickname: '万里长征只等闲', commentTime: '03-20 15:15', commentContent: '谁说没有专业狙击手,抗日神剧神枪手一堆', zanNum: 300, img: '/public/images/3.jpg'},
      { id: 3, nickname: '万里长征只等闲', commentTime: '03-20 15:15', commentContent: '谁说没有专业狙击手,抗日神剧神枪手一堆', zanNum: 300, img: '/public/images/3.jpg'},
      { id: 4, nickname: '万里长征只等闲', commentTime: '03-20 15:15', commentContent: '谁说没有专业狙击手,抗日神剧神枪手一堆', zanNum: 300, img: '/public/images/3.jpg'}
    ]
    var that = this;
    wx.getSystemInfo({
      success: function (res) {
        that.setData({
          page_height: res.windowHeight,
          commentList: data,
          commentContent: '',
        })
      },
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    return {
      title: '自定义分享标题',
      path: '/page/user?id=123',
      success: function (res) {
        console.log(1)
      },
      fail: function (res) {
        // 转发失败
        console.log(2)
      }
    }
  },
  markChange:function(e){
    var to = this.data.toView,val
    if (to == 'mark-1'){
      val = 'mark-2';
    }else{
      val = 'mark-1';
    }
    this.setData({
      toView:val
    })
  },
  tijiao:function(e){
    console.log(e.detail)
    var data = [
      { id: 1, nickname: '万里长征只等闲', commentTime: '03-20 15:15', commentContent: e.detail.value, zanNum: 300, img: '/public/images/3.jpg' }
    ]
    var l = this.data.commentList
    for (var i = 0;i<data.length;i++){
      l.push(data[i])
    }
    this.setData({
      commentList: l,
      commentContent:''
    })
  }
})